package mil.af.amc.adpetracker.web.actions.Ros;

import mil.af.amc.adpetracker.web.actions.AbstractAction;
import mil.af.amc.adpetracker.service.RosService;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;
import org.springframework.beans.factory.annotation.Required;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */

public class EditRosAction extends AbstractAction {

    private RosService rosService;

    @Required
    public void setRosService(RosService rosService) {
        this.rosService = rosService;
    }

    @Override
    public ActionForward execute(ActionMapping actionMapping,
                                 ActionForm actionForm,
                                 HttpServletRequest httpServletRequest,
                                 HttpServletResponse httpServletResponse) throws Exception {

        //int rosPackageId = Integer.parseInt(httpServletRequest.getParameter("rosPackageId"));
        DynaActionForm form = (DynaActionForm) actionForm;
        rosService.editRos(form.getMap());

        // Convenience method for the account selection display
        httpServletRequest.setAttribute("adpeAccountId", form.get("adpeAccountId"));

        return actionMapping.findForward("success");
    }
}
